﻿using System;
using com.eforceglobal.crux.controllers;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        lblPageHeader.Text = ((BaseView)Page).ViewTitle;
        SessionData sessionData = new SessionData();
        if (sessionData.IsFirstTimeLogin)
        {
            Navigation1.Visible = false;
            VistaAddressBar1.Visible = false;
        }
        else
        {
            Navigation1.Visible = true;
            VistaAddressBar1.Visible = true;
        }
        if (!Page.IsPostBack)
        {
            
            SearchBox.UserName = string.Empty; //user name not required in this case
            SearchBox.Roles = sessionData.CurrentUserRole;
        }
    }

    protected override void OnInit(EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            VistaAddressBar1.Tree = UrlTreeNodeItems.Home;
        }
        base.OnInit(e);
    }
    protected override void OnLoad(EventArgs e)
    {
        SetVistaAddressBarImages();
        base.OnLoad(e);
    }

    private void SetVistaAddressBarImages()
    {
        try
        {
            string currentTheme = this.Page.Theme;
            VistaAddressBar1.ClosedImageUrl = "App_Themes/" + currentTheme + "/images/vab_arr-close.gif";
        }
        catch (Exception)
        {
            //nothing
        }
    }
}
